package com.ruihu.admin.module.business.log.interfacelog.domain.entity;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruihu.admin.common.domain.BaseEntity;
import com.ruihu.admin.module.business.log.interfacelog.domain.dto.ElectricUpdateMessageQueueAddDTO;
import com.ruihu.admin.module.business.log.interfacelog.domain.dto.ElectricUpdateMessageQueueDTO;
import com.ruihu.admin.module.business.log.interfacelog.domain.dto.ElectricUpdateMessageQueueUpdateDTO;
import lombok.Data;
import java.util.Objects;

/**
 * [  ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c)  瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date 2023-02-08 15:53:41
 * @since JDK1.8
 */

@Data
@TableName("t_electric_update_message_queue")
public class ElectricUpdateMessageQueueEntity extends BaseEntity {


    /**
     * 电芯编码
     */
    private String electricCoreCode;

    public static ElectricUpdateMessageQueueEntity convertToElectricUpdateMessageQueueEntity(ElectricUpdateMessageQueueAddDTO addDTO) {
        if (addDTO == null) {
            return null;
        }

        ElectricUpdateMessageQueueEntity entity = new ElectricUpdateMessageQueueEntity();
        entity.setElectricCoreCode(addDTO.getElectricCoreCode());
        return entity;
    }


    public static ElectricUpdateMessageQueueEntity convertToElectricUpdateMessageQueueEntity(ElectricUpdateMessageQueueUpdateDTO updateDTO) {
        if (updateDTO == null) {
           return null;
        }

        ElectricUpdateMessageQueueEntity entity = new ElectricUpdateMessageQueueEntity();
        entity.setId(updateDTO.getId());
        entity.setElectricCoreCode(updateDTO.getElectricCoreCode());
        return entity;
    }

    public static ElectricUpdateMessageQueueEntity convertToElectricUpdateMessageQueueEntity(ElectricUpdateMessageQueueDTO dto) {
        if (dto == null) {
           return null;
        }

        ElectricUpdateMessageQueueEntity entity = new ElectricUpdateMessageQueueEntity();
        entity.setId(dto.getId());
        entity.setElectricCoreCode(dto.getElectricCoreCode());
        return entity;
    }

    public static ElectricUpdateMessageQueueEntity copyIgnoreNullAndEmpty(ElectricUpdateMessageQueueEntity sourceEntity, ElectricUpdateMessageQueueEntity destEntity) {
        if (Objects.isNull(sourceEntity))
            return destEntity;
        if (Objects.nonNull(sourceEntity.getId())) {
           destEntity.setId(sourceEntity.getId());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getElectricCoreCode())) {
           destEntity.setElectricCoreCode(sourceEntity.getElectricCoreCode());
        }
        return destEntity;
    }
}
